package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.SysCompanyClassification;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysExpertCategory;
import com.ruoyi.system.service.ISysExpertCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专家品目Controller
 * 
 * @author ruoyi
 * @date 2024-07-30
 */
@RestController
@RequestMapping("/system/expertcategory")
public class SysExpertCategoryController extends BaseController
{
    @Autowired
    private ISysExpertCategoryService sysExpertCategoryService;

    /**
     * 查询专家品目列表
     */
    @PreAuthorize("@ss.hasPermi('system:expertcategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysExpertCategory sysExpertCategory)
    {
        startPage();
        List<SysExpertCategory> list = sysExpertCategoryService.selectSysExpertCategoryList(sysExpertCategory);
        return getDataTable(list);
    }

    /**
     * 查询专家品目列表
     */
    @PreAuthorize("@ss.hasPermi('system:expertcategory:lists')")
    @GetMapping("/lists")
    public AjaxResult lists(SysExpertCategory sysExpertCategory)
    {
        List<SysExpertCategory> list = sysExpertCategoryService.selectSysExpertCategoryList(sysExpertCategory);
        return success(list);
    }

    /**
     * 导出专家品目列表
     */
    @PreAuthorize("@ss.hasPermi('system:expertcategory:export')")
    @Log(title = "专家品目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysExpertCategory sysExpertCategory)
    {
        List<SysExpertCategory> list = sysExpertCategoryService.selectSysExpertCategoryList(sysExpertCategory);
        ExcelUtil<SysExpertCategory> util = new ExcelUtil<SysExpertCategory>(SysExpertCategory.class);
        util.exportExcel(response, list, "专家品目数据");
    }

    /**
     * 获取专家品目详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:expertcategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysExpertCategoryService.selectSysExpertCategoryById(id));
    }

    /**
     * 新增专家品目
     */
    @PreAuthorize("@ss.hasPermi('system:expertcategory:add')")
    @Log(title = "专家品目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysExpertCategory sysExpertCategory)
    {
        return toAjax(sysExpertCategoryService.insertSysExpertCategory(sysExpertCategory));
    }

    /**
     * 修改专家品目
     */
    @PreAuthorize("@ss.hasPermi('system:expertcategory:edit')")
    @Log(title = "专家品目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysExpertCategory sysExpertCategory)
    {
        return toAjax(sysExpertCategoryService.updateSysExpertCategory(sysExpertCategory));
    }

    /**
     * 删除专家品目
     */
    @PreAuthorize("@ss.hasPermi('system:expertcategory:remove')")
    @Log(title = "专家品目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysExpertCategoryService.deleteSysExpertCategoryByIds(ids));
    }

    /**
     * 状态修改
     */
    @PreAuthorize("@ss.hasPermi('system:expertcategory:edit')")
    @Log(title = "企业类型", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody SysExpertCategory sysExpertCategory)
    {
        return toAjax(sysExpertCategoryService.updateSysExpertCategorynStatus(sysExpertCategory));
    }
}
